package com.javaee.wordtree.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.javaee.wordtree.entity.ModelChat;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 模型聊天记录Mapper接口
 */
@Mapper
public interface ModelChatMapper extends BaseMapper<ModelChat> {

    /**
     * 根据用户ID查询聊天记录
     * 
     * @param userId 用户ID
     * @return 用户的聊天记录列表
     */
    @Select("SELECT * FROM model_chats WHERE user_id = #{userId} ORDER BY updated_at DESC")
    List<ModelChat> findChatsByUserId(@Param("userId") String userId);

    /**
     * 根据用户ID和聊天类型查询聊天记录
     * 
     * @param userId   用户ID
     * @param chatType 聊天类型
     * @return 用户的特定类型的聊天记录列表
     */
    @Select("SELECT * FROM model_chats WHERE user_id = #{userId} AND chat_type = #{chatType} ORDER BY updated_at DESC")
    List<ModelChat> findChatsByUserIdAndType(@Param("userId") String userId, @Param("chatType") String chatType);
}